package com.webapp.tguide.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.appengine.api.datastore.Key;

@XmlRootElement(name = "Category")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Category {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key categoryKey;
	
	@Persistent
	private String name;
	
	@Persistent
	private String imagePath;
	
	//used to bidirectional mapping 1 x 1		
	//@Persistent(mappedBy = "categoryType")		
	//private TouristPoint touristPoint;		
	
	public Category(String name, String imagePath){
		this.name = name;
		this.imagePath = imagePath;
	}
	
	//Default constructor
	public Category() {}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getImagePath() {
		return imagePath;
	}
	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	public Key getCategoryKey() {
		return categoryKey;
	}

	public void setCategoryKey(Key categoryKey) {
		this.categoryKey = categoryKey;
	}

//	public TouristPoint getTouristPoint() {
//		return touristPoint;
//	}
//
//	public void setTouristPoint(TouristPoint touristPoint) {
//		this.touristPoint = touristPoint;
//	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Category){
			Category c = (Category)obj;
			if (this.name.equals(c.getName())){
				return true;
			}
			return false;
		}
		return false;
	}
	
}
